﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VISS.API.Users;

namespace VISS.Web.BackEnd.Modules.User {

    public partial class ReportListControl : System.Web.UI.UserControl {

        public List<UserReportEnt> ReportList { get; set; }
        public bool DisplayLink;

        protected void Page_Load(object sender, EventArgs e) {
            if (ReportList != null && ReportList.Count > 0) {
                dtg_Report.DataSource = ReportList;
                dtg_Report.DataBind();
            }
        }

        protected void dtg_Report_RowDataBound(object sender, GridViewRowEventArgs e) {
            if (e.Row.RowIndex == -1)
                return;

            UserReportEnt item = (UserReportEnt)e.Row.DataItem;

            string info = string.Empty;
            info = "<a href=\"xem_chi_tiet?key=" + item.UserKey + "\">" + item.ReporterName + "</a> báo cáo về <a href=\"xem_chi_tiet?key=" + item.ReportedUserKey + "\">" + item.ReportedName + "</a>";
            e.Row.Cells[0].Text = info;

            string reason = string.Empty;
            reason = item.Reason;
            if (DisplayLink) {
                reason += "<br />";
                reason += "<a href=\"vi_pham?key=" + item.ReportedUserKey + "\">Báo cáo vi phạm về " + item.ReportedName + "</a>";
            }
            e.Row.Cells[1].Text = reason;            

            string action = string.Empty;
            action = "<input type=\"checkbox\" id=\"chkSetRead-" + item.ID + "\" onclick=\"DeleteReport('" + item.ID + "', '" + item.ReportedUserKey + "');\" /> <label for=\"chkSetRead-" + item.ID + "\">Xóa</label> <br />";
            

            e.Row.Cells[2].Text = action;
        }
    }
}
